#!/usr/bin/env python

import sys, os
import getopt

Version = 3.0
ProgramName = "PetaIMGUP-GTK"

file = None
tmpfile = ".tmpfile1"

def Usage():
	print "Usage: " + sys.argv[0] + " -f <file> | -h"
	print "       -h            Help Information for this document"
	print "       -f <file>     Upload image and show information"
	print ""
	print "Example: "
	print "  " + sys.argv[0] + " -f mymage.png"
	print ""
	print str(ProgramName) + str(Version) + " by Oytun Ozdemir <oytunozdemir@gmail.com>"
	
def Main():
	try:
		if len(sys.argv) < 2:
			Usage()
			exit()
		opts = getopt.getopt(sys.argv[1:], "hf:")
		for i in opts[0]:
			if i[0] == "-h":
				Usage()
			elif i[0] == "-f":
				file = i[1]
				print "Uploading...." + file
				tmptext = ".tmtext"
				linktext = "'Picture Uploaded'"
				cmd = "petauploader -f " + file + " > " + tmptext
				cmd2 = "zenity --info --text=$(cat " + tmptext + ") --title=" + str(linktext)
				os.system(cmd)
				os.system(cmd2)
				os.system("rm -rf .tmtext")
	except getopt.GetoptError, error:
		print error
		Usage()

Main()
